import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "../views/home.vue"
import Shop from "../views/shop.vue"
import Tuijian from "../views/tuijian.vue"
import Fruit from "../views/fruit.vue"
import Xiangqing from "../views/xiangqing.vue"
import Likexq from "../views/likexq.vue"


Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'home',
    component: Home,
    children: [
      {
        path: '/',
        name: 'tuijian',
        component: Tuijian,
      },
      {
        path: '/tuijian',
        name: 'tuijian',
        component: Tuijian,
      },
      {
        path: '/fruit',
        name: 'fruit',
        component: Fruit
      }
    ]
  },


  {
    path: '/compay',
    name: 'compay',
    component: () => import('../views/compay.vue')
  },
  {
    path: '/shops',
    name: 'shops',
    component: () => import('../views/shops.vue'),

  },
  {
    path: '/some',
    name: 'some',
    component: () => import('../views/some.vue')
  },
  {
    path: '/somezi',
    name: 'somezi',
    component: () => import('../views/somezi.vue')
  },
  {
    path: '/shop/:id',
    name: 'shop',
    component: Shop
  },

  {
    path: '/aboutme',
    name: 'aboutme',
    component: () => import('../views/aboutme.vue')
  },
  {
    path: '/xiangqing/:id',
    name: 'xiangqing',
    component: Xiangqing
  },
  {
    path: '/likexq/:id',
    name: 'likexq',
    component: Likexq
  },

  {
    path: '/newfind',
    name: 'newfind',
    component: () => import('../views/newfind.vue')
  },
  {
    path: '/newfind/:goodsid',
    name: 'Newfind',
    component: () => import('../views/newfind.vue')
  },
  {
    path: '/set',
    name: 'set',
    component: () => import('../views/set.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login.vue')
  },
  {
    path: '/movie',
    name: 'movie',
    component: () => import('../views/movie.vue')
  },
  {
    path: '/',
    redirect: "/Home",
    component: () => import('../views/rigster.vue')
  },

  {
    path: '/rigster',
    name: 'rigster',
    component: () => import('../views/rigster.vue')
  },
  {
    path: '/fulihaoquan',
    name: 'fulihaoquan',
    component: () => import('../views/fulihaoquan.vue')
  },
  {
    path: '*',
    name: '404',
    component: () => import('../views/404.vue')
  }
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// router.beforeEach((to, from, next) => {
//   if (to.path == "/shops") {
//     if (localStorage.getItem("user") == "") {
//       alert("您没有登录请您登录后在试！！！")
//       next("/aboutme")
//     } else {
//       next()
//     }
//   } else {
//     next()
//   }


// })


export default router
